//
//  MessageTableViewCell.m
//  QT
//
//  Created by 甘世清 on 2024/12/28.
//

#import "MessageTableViewCell.h"

@implementation MessageTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
   
    UIView * bgView = [[UIView alloc]init];
    bgView.backgroundColor = UIColor.whiteColor;
    bgView.layer.cornerRadius = 10;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(10, 12, 5, 12));
    }];
    [bgView addSubview:self.leftImageView];
    [bgView addSubview:self.titleLabel];
    [bgView addSubview:self.rightBtn];
    [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(16);
        make.left.equalTo(bgView).offset(12);
        make.top.equalTo(bgView).offset(17);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(34);
        make.centerY.equalTo(self.leftImageView);
    }];
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(50);
            make.top.right.equalTo(bgView);
    }];
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQHexColor(@"#000000", 0.2);
    [bgView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(bgView);
        make.top.equalTo(bgView).offset(50);
        make.height.mas_equalTo(0.4);
    }];
    [bgView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(12);
        make.top.equalTo(lineView.mas_bottom).offset(16);
    }];
    [bgView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(12);
        make.right.equalTo(bgView.mas_right).offset(-12);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(18);
    }];
    
    self.FS_cellBottomView = self.messageLabel;
}
- (void)setModel:(SystemModel *)model{
    _model = model;
    [self.leftImageView sd_setImageWithURL:SQURLImage(model.portrait)];
    self.titleLabel.text = model.title;
    self.timeLabel.text = model.createTime;
    self.messageLabel.text = model.content;
}

- (UIImageView *)leftImageView{
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc]init];
    }
    return _leftImageView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = FONT_MEDIUM(12);
        _titleLabel.textColor = SQColor666666;
    }
    return _titleLabel;
}
- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = FONT_MEDIUM(12);
        _timeLabel.textColor = SQColor999999;
    }
    return _timeLabel;
}
- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_MEDIUM(14);
        _messageLabel.numberOfLines = 0;
        _messageLabel.textColor = SQColor333333;
    }
    return _messageLabel;
}
- (SQCustomButton *)rightBtn{
    if (!_rightBtn) {
        _rightBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _rightBtn.text = SQNSLocalString(@"管理");
        _rightBtn.font = FONT_REGULAR(12);
        _rightBtn.textColor = SQColor333333;
    }
    return _rightBtn;
}
@end
